<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">

                <p:panel header="Edit Details" style="margin: auto; width: 700px; margin-top: 20px;" >

                    <h:form>



                        <p:panel header="Patient Details" style="margin: auto;" >

                            <h:panelGrid columns="2" >
                                <h:outputLabel value="Title"/>
                                <p:selectOneMenu  id="cmbTitle" value="#{patientController.current.person.title}"  >
                                    <f:selectItem itemLabel="Select Title" />
                                    <f:selectItems value="#{billController.title}" var="i" 
                                                   itemLabel="#{i.label}" itemValue="#{i}"/>
                                </p:selectOneMenu>
                                <h:outputLabel value="Name"/>
                                <p:inputText autocomplete="off"  id="txtNewPtName" value="#{patientController.current.person.name}" style="width: 200px;text-transform:capitalize;">
                                </p:inputText>
                                <h:outputLabel value="Sex"/>
                                <p:selectOneMenu id="txtNewSex"  value="#{patientController.current.person.sex}" style="width: 200px;">
                                    <f:selectItem itemLabel="Select Gender"/>
                                    <f:selectItems value="#{billController.sex}"/>
                                </p:selectOneMenu>

                                <h:outputLabel value="Date of Birth"/>
                                <h:panelGrid columns="4">
                                    <p:inputText autocomplete="off"  id="year"  
                                                 value="#{patientController.yearMonthDay.year}" 
                                                 style="width: 50px; ">
                                        <f:ajax event="keyup" execute="@this month day" render="calNewPtDob" 

                                                listener="#{patientController.dateChangeListen()}"  />
                                    </p:inputText>
                                    <p:inputText autocomplete="off" id="month"
                                                 style="width: 50px; " value="#{patientController.yearMonthDay.month}">
                                        <f:ajax event="keyup" execute="@this year day" render="calNewPtDob" listener="#{billController.dateChangeListen()}"  />
                                    </p:inputText>
                                    <p:inputText autocomplete="off" id="day" 
                                                 style="width: 50px;" value="#{patientController.yearMonthDay.day}">
                                        <f:ajax event="keyup" execute="@this year month" render="calNewPtDob" listener="#{billController.dateChangeListen()}" />
                                    </p:inputText>

                                </h:panelGrid>

                                <h:outputLabel value="Phone"/>
                                <p:calendar  value="#{patientController.current.person.dob}" 
                                             id="calNewPtDob"  navigator="true" pattern="dd/MM/yyyy" 
                                             style="width: 100px!important;"
                                             styleClass="shortinput">
                                    <f:ajax event="dateSelect" />
                                </p:calendar>

                                <h:outputLabel value="Phone"/>
                                <p:inputText autocomplete="off"  id="txtPhone" value="#{patientController.current.person.phone}" style="width: 200px;text-transform:capitalize;">
                                </p:inputText>

                                <h:outputLabel value="Email"/>
                                <p:inputText autocomplete="off"  id="txtEmail" value="#{patientController.current.person.email}" style="width: 200px;">
                                </p:inputText>

                                <h:outputLabel value="NIC"/>
                                <p:inputText autocomplete="off"  id="txtNic" value="#{patientController.current.person.nic}" style="width: 200px;text-transform:capitalize;">
                                </p:inputText>

                                <h:outputLabel value="Area"/>
                                <p:autoComplete id="acNewPtArea" converter="areaCon" placeholder="Search &amp; Select Area"
                                                completeMethod="#{areaController.completeArea}" 
                                                var="pta" itemLabel="#{pta.name}" styleClass="shortinputOpd"
                                                itemValue="#{pta}" forceSelection="true" 
                                                value="#{patientController.current.person.area}" ></p:autoComplete>


                                <h:outputLabel value="Address"/>
                                <p:inputText autocomplete="off"  id="txtAddress" 
                                             value="#{patientController.current.person.address}" style="width: 400px;text-transform:capitalize;">
                                </p:inputText>


                                <h:outputLabel value="PHN No"/>
                                <p:inputText autocomplete="off"  id="txtNewPtName1" value="#{patientController.current.phn}" style="width: 200px;text-transform:capitalize;">
                                </p:inputText>









                            </h:panelGrid>

                        </p:panel>



                        <p:panel>

                            <p:commandButton value="Update" action="#{patientController.saveSelectedPatient()}"
                                             ajax="false" onclick="if (!confirm('Are you sure you want to save this record?'))
                                                      return false;"></p:commandButton>

                        </p:panel>

                    </h:form>

                </p:panel>

            </ui:define>

        </ui:composition>

    </h:body>
</html>
